<? 
session_start();
				
include ('conn.php');
				
$db = get_conn();
				
check_session();
		  
if ($_POST['Agregar']!=""){
	$sql = "INSERT INTO facilities (id_ftype,name,address,address2) VALUES (
	".($_POST['id_ftype']).",
	\"".htmlspecialchars($_POST['name'])."\",
	\"".htmlspecialchars($_POST['address'])."\",
	\"".htmlspecialchars($_POST['address2'])."\")";
			
	$result = mysql_query($sql);
			
 	if($result){
			
 		do_redirect('../facilities.php'); 	  
			
 	}else{
			
 		error_handling('facilities.insert  - '.$sql,mysql_error());
			
 	}				  
		 
}//Agregar
		  
if ($_POST['Actualizar']!=""){
			
	$sql = "update facilities set 
	id_ftype=".$_POST['id_ftype'].",
	name=\"".htmlspecialchars($_POST['name'])."\",
	address=\"".htmlspecialchars($_POST['address'])."\",
	address2=\"".htmlspecialchars($_POST['address2'])."\"
 
	where id_facility=".$_POST['id_facility'];
			 
			
	$result = mysql_query($sql);
			
	if($result){
				
		do_redirect('../facilities.php'); 	  
					
			
	}else{
				
		error_handling('facilities.update - '.$sql,mysql_error());
			
	}				  
		 
}//update
		  
if ($_POST['Eliminar']!=""){
			
	$sql = "delete from facilities where id_facility=".$_POST['id_facility'];
			
	$result = mysql_query($sql);
			
	if($result){
				
		do_redirect('../facilities.php'); 	  
			
	}else{
				
		error_handling('facilities.delete - '.$sql,mysql_error());
			
	}				  
		 
}//delete
		  
if ($_POST['Nuevo']!=""){
				
		do_redirect('../facilities.php'); 	  
		  
}//nuevo

?>